@extends('layouts.app')

@section('content')

            <div class="col-md-12">
                <div class="panel panel-default">
                    <div class="panel-heading">增加权限</div>

                    <div class="panel-body">
                        <form class="form-inline" action="{{ url('/admin/permission/permission') }}" method="post">
                            {{ csrf_field() }}
                            <div class="form-group">
                                <label>权限名：</label>
                                <input type="text" class="form-control" name="name">
                            </div>
                            <div class="form-group">
                                <label>显示名：</label>
                                <input type="text" class="form-control" name="display_name" placeholder="非必填">
                            </div>
                            <div class="form-group">
                                <label>描述：</label>
                                <input type="text" class="form-control" name="description" placeholder="非必填">
                            </div>
                            <button type="submit" class="btn btn-primary">增加</button>
                        </form>


                    </div>
                </div>
            </div>
            <div class="col-md-12">
                <div class="panel panel-default">
                    <div class="panel-heading">权限列表</div>

                    <div class="panel-body">

                        @if($permissions->count() > 0)
                        <table class="table">
                            <thead>
                            <tr>
                                <th>id</th>
                                <td>权限代号</td>
                                <td>权限名</td>
                                <td>描述</td>
                                <td>操作</td>
                            </tr>
                            </thead>
                            <tbody>
                                @foreach($permissions as $permission)
                                    <tr>
                                        <th>{{ $permission->id }}</th>
                                        <td>{{ $permission->name }}</td>
                                        <td>{{ $permission->display_name }}</td>
                                        <td>{{ $permission->description }}</td>
                                        <td>
                                            <button class="btn btn-danger btn-sm" onclick="document.getElementById('permission-delete-{{ $permission->id }}').submit();">删除</button>
                                            <form action="{{ url('/admin/permission/permission', $permission->id) }}" id="permission-delete-{{ $permission->id }}" method="post">
                                                {{ csrf_field() }}
                                                {{ method_field('DELETE') }}
                                            </form>
                                        </td>
                                    </tr>
                                @endforeach
                            </tbody>
                        </table>
                        @endif

                    </div>
                </div>
            </div>
        </div>
    </div>
@endsection

